package com.egg.ylt.presenter.impl;

import com.egg.ylt.Utils.API;
import com.egg.ylt.pojo.MemberCardListEntity;
import com.egg.ylt.presenter.ITimeCardPresenter;
import com.egg.ylt.view.ITimeCardView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

/**
 * Created by sichaoqi on 2018/10/8.
 */

public class TimeCardPresenterImpl extends BasePresenter<ITimeCardView> implements ITimeCardPresenter {
    @Override
    public void getCardList(String token, String companyId) {
        mView.showDialogLoading("数据加载中");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("token", token);
        hashMap.put("companyId", companyId);
        RequestManager.getInstance().requestPostByAsyn(API.GET_MEMBER_CARD_LIST, hashMap, new ReqCallBack<MemberCardListEntity>() {

            @Override
            public void onReqSuccess(MemberCardListEntity result) {
                mView.dismissDialogLoading();
                mView.getCardList(result);
            }

            @Override
            public void onFailure(String result) {
                mView.dismissDialogLoading();
                mView.showError(result);
                CommonUtils.makeEventToast(mContext, result, false);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
                mView.dismissDialogLoading();
                mView.showException(error.toString());
                CommonUtils.makeEventToast(mContext, error.getMsg(), false);
            }
        });
    }
}
